// -----------------------------------------------------------
// Game Framework
// Copyright © 2024-2024 deadcycle. All rights reserved.
// Homepage: https://deadcycle.gitee.io
// Feedback: deadcycle@163.com
// -----------------------------------------------------------

#if ODIN_INSPECTOR

using System;
using System.Collections.Generic;
using System.Reflection;

using Sirenix.OdinInspector;
using Sirenix.OdinInspector.Editor;

namespace UIWidget.Editor
{
    public class FlipMeshEffectInspector { }

    public class FlipMeshEffectAttrProcessor : OdinAttributeProcessor<FlipMeshEffect>
    {
        private readonly Dictionary<string, Action<List<Attribute>>> m_FieldProcessorDict;

        public FlipMeshEffectAttrProcessor()
        {
            m_FieldProcessorDict = new Dictionary<string, Action<List<Attribute>>>
            {
                { "m_HorizontalFlip", FieldHorizontalFlip },
                { "m_VerticalFlip", FieldVerticalFlip },
            };
        }

        public override void ProcessChildMemberAttributes(InspectorProperty parentProperty,
            MemberInfo member,
            List<Attribute> attributes)
        {
            if (member.MemberType == MemberTypes.Field &&
                m_FieldProcessorDict.TryGetValue(member.Name,
                    out Action<List<Attribute>> fieldProcessor))
            {
                fieldProcessor.Invoke(attributes);
            }
        }

        private void FieldHorizontalFlip(List<Attribute> attributes)
        {
            attributes.Add(new LabelTextAttribute("水平镜像翻转"));
        }

        private void FieldVerticalFlip(List<Attribute> attributes)
        {
            attributes.Add(new LabelTextAttribute("垂直镜像翻转"));
        }
    }
}

#endif